﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditPStock.aspx.cs" Inherits="Skyworth.CRM.Web.BasicData.EditPStock" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>销售管理平台 | 修改仓库</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <%--[if IE]>
     <link href="../themes/css/ieHack.css" rel="stylesheet" type="text/css" />
    <![endif]--%>
    <script src="../javascripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <link href="../themes/silver/style.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/core.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/pages.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/wbox.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/Messagebox.css" rel="stylesheet" type="text/css" />
    <script src="../javascripts/jquery.autocomplete.js" type="text/javascript"></script>
     <style type="text/css">        
        a
        {
            display: block;
        }
        .red
        {
            color: Red;
            font-weight: bold;
        }       
        table
        {
            border-collapse: collapse;
            border-spacing: 0;
            table-layout: fixed;
            width: 100%;
            border: solid 1px #e7e7e7;
        }
        table tr td
        {
            border-bottom: solid 1px #e7e7e7;
            padding: 0px 3px;
            background-color: #EFEFEF;
        }
        td label
        {
            padding: 2px 2px;
        }
        td.left
        {
            border-right: solid 1px #e7e7e7;
            width: 65px;
        }
        td.right
        {
            background: #FFF;
        }
        td.right, td.readOnly
        {
            padding: 5px 3px;
        }
        .content
        {
            overflow: auto;           
            border: solid 1px #CCC;
            line-height: 21px;
            background: #FFF;
            padding: 5px;
        }
        input[type=text]
        {
 	        width:180px;
        }
        select
        {
        	width:185px;
        	height:25px;
        }
        
    </style>
     <script type="text/javascript">
         function SaveCheck() {
             var txtStockCode = $("#txtStockCode");
             var stockCode = txtStockCode.val();
             var txtStockName = $("#txtStockName");
             var stockName = txtStockName.val();
             var hidDepartId = $("#hidDepartId");
             var departId = hidDepartId.val();             
             if (stockCode == "" || stockCode.length <= 0) {
                 alert("请输入仓库代码！");
                 txtStockCode.focus();
                 return false;
             }
             if (stockName == "" || stockName.length <= 0) {
                 alert("请输入仓库名称！");
                 txtStockName.focus();
                 return false;
             }
             if (departId == "" || departId.length <= 0) {
                 if ($("#ddlstStockType").val() == "1")
                 { alert("请输入客户！"); }
                 else
                 { alert("请输入部门！"); }                 
                 $("#txtDepartName").focus();
                 return false;
             }
         }

         $(document).ready(function () {
             $("input[type=text],textarea").addClass("textInput").focus(function () { $(this).addClass("focus"); }).blur(function () { $(this).removeClass("focus") });

             $("#txtCustName").autocomplete("../Service/CustomerHandler.ashx", {
                 minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                 formatItem: function (result, i, max) {
                     var item = "<span>" + result[1] + "</span>"
                     return item;
                 },
                 //extraParams: { CustId: 0 },
                 formatResult: function (row) { return row[1]; }
             });
             $("#txtCustName").result(function (event, data, formatted) {
                 if (data && data.length > 0) {
                     $("#hidDepartId").val(data[0]);
                 }
             });

             $("#txtDepartId").autocomplete("../Service/DepartmentHandler.ashx", {
                 minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                 formatItem: function (result, i, max) {
                     var item = "<span>" + result[1] + "</span>"
                     return item;
                 },
                 //extraParams: { CustId: 0 },
                 formatResult: function (row) { return row[1]; }
             });
             $("#txtDepartId").result(function (event, data, formatted) {
                 if (data && data.length > 0) {
                     $("#hidDepartId").val(data[0]);
                 }
             });

             $("#ddlstStockType").change(function () {                 
                 return ChangeData();
             })

             $("#txtDepartName").autocomplete("../Service/CustomerHandler.ashx", {
                 minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                 formatItem: function (result, i, max) {
                     var item = "<span>" + result[1] + "</span>"
                     return item;
                 },
                 //extraParams: { CustId: 0 },
                 formatResult: function (row) { return row[1]; }
             });
             $("#txtDepartName").result(function (event, data, formatted) {
                 if (data && data.length > 0) {
                     $("#hidDepartId").val(data[0]);
                 }
             });

             $("#btnClose").click(function () {
                 parent.addWindow.close();
             })
             $("#btnSave").click(function () {
                 return SaveCheck();
             })

             $("div.button").hover(function () { $(this).addClass("buttonHover"); },
               function () { $(this).removeClass("buttonHover"); });

             if ($("#ddlstStockType").val() == "1") {
                 $("#lblDept").html("客户：");
                 $("#txtCustName").css("display", "block");
                 $("#txtDepartId").css("display", "none");    
             }
             else {
                 $("#lblDept").html("部门：");
                 $("#txtCustName").css("display", "none");
                 $("#txtDepartId").css("display", "block");   
             }
         })

         function ChangeData() {
             var ddlstStockType = $("#ddlstStockType").val();
             if (ddlstStockType == "1") {
                 $("#lblDept").html("客户：");
                 $("#txtCustName").css("display", "block");
                 $("#txtDepartId").css("display", "none");                   
             }
             else {
                 $("#lblDept").html("部门：");
                 $("#txtCustName").css("display", "none");
                 $("#txtDepartId").css("display", "block");               
             }
         }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <div style="margin:2px;">
            <div class="panel" >
                <div class="panelHeader">
                    <div class="panelHeaderContent">
                        <h1>
                            仓库信息</h1>
                    </div>
                </div>
                <div class="panelContent">
                    <div class="content" >
        <table>
            <tr>
                <td class="left">
                    <label>仓库代码：</label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtStockCode" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox><em class="red">*</em>
                </td>
                <td class="left">
                    <label>仓库名称：</label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtStockName" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox><em class="red">*</em>
                </td>
            </tr>
            <tr>
               <td class="left">
                    <label>仓库类型：</label>
                </td>
                <td class="right">
                    <asp:DropDownList ID="ddlstStockType" runat="server">
                        <asp:ListItem Value="1">经销商</asp:ListItem>
                        <asp:ListItem Value="2">分公司</asp:ListItem>
                        <asp:ListItem Value="3">总部</asp:ListItem>                        
                    </asp:DropDownList>
                </td>
                <td class="left"><asp:Label ID="lblDept" Text="客户：" runat="server"></asp:Label></td>
                <td class="right">
                    <input ID="txtCustName" type="text" runat="server" class="txt" />
                    <input ID="txtDepartId" style="display: none;" type="text" runat="server" class="txt" />
                    <input type="hidden" style="display: none;" id="hidDepartId" runat="server" />
                </td>
            </tr>            
            <tr>                
                <td class="left">
                    <label>财务联系人：</label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtContact" CssClass="txt" runat="server" MaxLength="30"></asp:TextBox>
                </td>
                 <td class="left">
                    <label>仓库联系人：</label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtStocker" CssClass="txt" runat="server" MaxLength="30"></asp:TextBox>
                </td>
            </tr>          
             <tr>               
                <td class="left">
                    <label>电话：</label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtTel" CssClass="txt" runat="server" MaxLength="20"></asp:TextBox>
                </td>  
                 <td class="left">
                    <label>手机：</label>
                </td>
                <td class="right">
                    <asp:TextBox ID="txtMobile" CssClass="txt" runat="server" MaxLength="20"></asp:TextBox>
                </td>
            </tr>
            <tr>               
                <td class="left">
                    <label>仓库地址：</label>
                </td>
                <td class="right" colspan="3">
                     <asp:TextBox ID="txtAddress" Width="450px" CssClass="txt" runat="server" MaxLength="200"></asp:TextBox>
                </td>
            </tr>                 
            <tr>
                <td colspan="4" class="readOnly" style="padding-right: 12px; background: url('../themes/default/images/grid/grid.png') repeat scroll 0 0">
                                   <a title="清空" href="javascript:void(0)" class="button" style="float:left" id="btnClose"><span>关闭</span></a>
                                   
                                    <div class="button" style="float: right;margin-right: 5px;">
                                        <div class="buttonContent">
                                            <asp:Button ID="btnSave" runat="server" Text="保存" 
                                                CssClass="serverButton" onclick="btnSave_Click" />
                                        </div>
                                    </div>
                                    <div style="clear:both;float:none;display:none;"></div>
                </td>
            </tr>
        </table>
    </div>
                </div>
                <div class="panelFooter">
                    <div class="panelFooterContent">                        
                    </div>
               </div> 
           </div>
        </div>
    </div>
    </form>
</body>
</html>